In [1]:
%run ../common.ipynb


Populating the interactive namespace from numpy and matplotlib

In [2]:
images = imread('tilescan.tif')

In [4]:
len(images)


Out[4]:
273

In [9]:
imsave?
Parameters ---------- filename : str Name of file to write. data : array_like Input image. The last dimensions are assumed to be image depth, height, width, and samples. kwargs : dict Parameters 'byteorder', 'bigtiff', and 'software' are passed to the TiffWriter class. Parameters 'photometric', 'planarconfig', 'resolution', 'description', 'compress', 'volume', and 'extratags' are passed to the TiffWriter.save function. Examples -------- >>> data = numpy.random.rand(2, 5, 3, 301, 219) >>> description = u'{"shape": %s}' % str(list(data.shape)) >>> imsave('temp.tif', data, compress=6, ... extratags=[(270, 's', 0, description, True)])

In [8]:
for i, img in enumerate(images):
    if i < 10:
        j = '00' + str(i)
    elif i > 10 and i < 100:
        j = '0' + str(i)
    else:
        j = str(i)
    imsave('images/' + j + '.tif', img)